package game.metalmax.module.server
{
	import flash.utils.Dictionary;

	public final class GateWay
	{
		static private var moduleCallbacks:Dictionary = null;
		
		{
			moduleCallbacks = new Dictionary();
		}
		
		static public function register(header:int, callback:Function):void
		{
			moduleCallbacks[header] = callback;
		}
	
		static public function dispatch(header:int, packet:Object):void
		{
			if (moduleCallbacks.hasOwnProperty(header))
			{
				moduleCallbacks[header](packet);	
			}
			else
			{
				throw new Error("[GateWay] not find callback mapping with the header.");
			}
			
		}
	}
}